package br.ufrj.dcc.ad.model;

public class Package {

	private final Long leftByte;
	private final Integer sessionId;
	private final Double propagationTime;
	private Double sentTime;
	private Boolean retransmitted;
	
	public Package(Long leftByte, Integer sessionId, Double propagationTime, Boolean retransmitted) {
		this.leftByte = leftByte;
		this.sessionId = sessionId;
		this.propagationTime = propagationTime;
		this.setRetransmitted(retransmitted);
	}
	
	public Package(Long leftByte, Integer sessionId, Double propagationTime) {
		this.leftByte = leftByte;
		this.sessionId = sessionId;
		this.propagationTime = propagationTime;
		this.setRetransmitted(false);
	}

	public Integer getSessionId() {
		return sessionId;
	}


	public Double getPropagationTime() {
		return propagationTime;
	}

	public Long getLeftByte() {
		return leftByte;
	}

	@Override
	public String toString() {
		return "Pacote-" + leftByte;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((leftByte == null) ? 0 : leftByte.hashCode());
		result = prime * result
				+ ((propagationTime == null) ? 0 : propagationTime.hashCode());
		result = prime * result
				+ ((sessionId == null) ? 0 : sessionId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Package other = (Package) obj;
		if (leftByte == null) {
			if (other.leftByte != null)
				return false;
		} else if (!leftByte.equals(other.leftByte))
			return false;
		if (propagationTime == null) {
			if (other.propagationTime != null)
				return false;
		} else if (!propagationTime.equals(other.propagationTime))
			return false;
		if (sessionId == null) {
			if (other.sessionId != null)
				return false;
		} else if (!sessionId.equals(other.sessionId))
			return false;
		return true;
	}

	public Double getSentTime() {
		return sentTime;
	}

	public void setSentTime(Double sentTime) {
		this.sentTime = sentTime;
	}

	public Boolean getRetransmitted() {
		return retransmitted;
	}

	public void setRetransmitted(Boolean retransmitted) {
		this.retransmitted = retransmitted;
	}
	
	

}
